﻿namespace Hydrogen.MathExt.Expression.Functions
{
    internal class FunctionRandom : FunctionRandomBase
    {
        public override int ArgCount => 2;
        public override double Evaluate(params double[] args)
        {
            var min = GetArg(args,0);
            var max = GetArg(args,1);

            if(max < min)
            {
                var v = min;
                min = max;
                max = v;
            }
            
            var random = _random.NextDouble();
            return min + (max - min) * random;
        }
    }
}
